package com.hqbzl.chat.constant;

import com.google.common.collect.ImmutableListMultimap;
import com.hqbzl.chat.message.RpcRequestMessage;
import com.hqbzl.chat.message.RpcResponseMessage;
import com.hqbzl.chat.model.*;
import io.netty.util.concurrent.Promise;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

public class Constants {

    public static ImmutableListMultimap<Integer, Class> MESSAGEID_TO_CLSS = ImmutableListMultimap.<Integer, Class>builder().build();
    public static ConcurrentMap<Integer, Class> MESSAGE_TYPE_MAP = new ConcurrentHashMap<>();

    public static final int PING_REQUEST_MSG_TYPE = 0;

    public static final int RPC_REQUEST_MSG_TYPE = 100;
    public static final int RPC_RESPONSE_MSG_TYPE = 101;

    static {
        MESSAGE_TYPE_MAP.put(RPC_REQUEST_MSG_TYPE, RpcRequestMessage.class);
        MESSAGE_TYPE_MAP.put(RPC_RESPONSE_MSG_TYPE, RpcResponseMessage.class);
    }

    public static ConcurrentHashMap<Integer, Promise<Object>> PROMISE_MAP = new ConcurrentHashMap<>();

}
